package entity

import (
	"html"
	"strings"
	"time"
)

type File struct {
	//gorm.Model
	ID               uint64 `gorm:"index"`
	CatalogID        uint64
	CatalogInnerCode string `gorm:"type:varchar(255)"`
	FileName         string `gorm:"size:255;null;" json:"filename"`
	FileSize         uint64
	Suffix           string `gorm:"type:varchar(64)"`
	Path             string `gorm:"size:255;null;" json:"path"`
	LinkFlag         string `gorm:"size:2;null;" json:"link_flag"`
	LinkID           uint64
	AddUser          string    `gorm:"size:50;null" json:"adduser"`
	AddTime          time.Time `gorm:"default:CURRENT_TIMESTAMP"`
}

func (File) TableName() string {
	return "zefile"
}

func (f *File) BeforSave() {
	f.FileName = html.EscapeString(strings.TrimSpace(f.FileName))
}
